package com.znf4.controller.platform;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.PostConstruct;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.socket.TextMessage;

import com.alibaba.fastjson.JSONObject;
import com.znf4.controller.notice.NoticeController;
import com.znf4.controller.search.lucene.IndexService;
import com.znf4.notice.entity.Notice;
import com.znf4.notice.enums.NoticeStatusEnum;

@Controller
@RequestMapping("/search")
public class SearchController {
	
	private static final Logger LOG = LoggerFactory.getLogger(SearchController.class);
	
	@Autowired
	private IndexService indexService ;
	
	/**
	 * 类加载的时候创建索引
	 *//*
	@PostConstruct
	public void init() {
		
		LOG.info("lucene index init ........初始化lucene");
		//index 索引初始化
		indexService.createIndexDump() ;
	}
	

	
	
	*//**
	 * 搜索索引库 sort 1 : 价格 ，2 :新旧 , 3 : 推荐 , 4 : 点击量
	 *//*
	@RequestMapping(value = "/lucene/showList", method = RequestMethod.GET)
	public String showList(String queryString, String good_type2_name, String price, Integer page, String sort,
			Model model) {   System.out.println("page  de 值  ："  + page  );
		// 如果不指定page默认为第一页
		if (page == null) {
			page = 1;
		}
		GoodResult proList = new GoodResult();

		// 根据分类查询分类列表
		proList = indexService.getProductList(queryString, good_type2_name, price, page, sort);

		// 回传分类id
		model.addAttribute("queryString", queryString);
		model.addAttribute("good_type2_name", good_type2_name);
		model.addAttribute("price", price);
		model.addAttribute("sort", sort);
		model.addAttribute("recordCount", proList.getRecordCount());
		model.addAttribute("pageCount", proList.getPageCount());
		model.addAttribute("curPage", proList.getCurPage());
		model.addAttribute("recordCount", proList.getRecordCount());
		// 回传商品列表
		model.addAttribute("allGoods", proList.getProductList());

		// 搜索结果列表页 获取推荐商品 limit 9 , 5
		Map<String, Object> map2 = new HashMap<String, Object>();
		map2.put("start_num", 18);
		map2.put("nums", 12);
		List<Goods> list_tj = goodService.findGoodsByStateAndTj(map2);
		System.out.println("搜索获取推荐商品的个数 ：" + list_tj.size());
		model.addAttribute("tjGoods", list_tj);

		return "buyer/goodlist";
	}

	
	*/
	
	
	


}
